package com.hollycrm.hollysqm.analyzer.solr.action.impl;

import com.hollycrm.hollysqm.analyzer.solr.action.Act;
import com.hollycrm.hollysqm.analyzer.solr.auth.SolrAuthentication;
import com.hollycrm.hollysqm.analyzer.util.ConfigUtil;
import com.hollycrm.hollysqm.analyzer.util.Constant;

import java.sql.SQLException;

/**
 * Created by zhaihw on 2016/5/4.
 * 刷新solrcloud权限列表
 */
public class FlushSolrAuthAct implements Act {
    /**
     * 执行方法
     */
    @Override
    public String execute() {
        String jsonTemp = ConfigUtil.getProp(Constant.jsonTemp);
        boolean b = false;
        String msg ;
        try {
            SolrAuthentication.INSTANCE.loadAvailableIps();
            b = true;
            msg = "success";
        } catch (SQLException e) {
            msg = "error,查询数据库记录出错";
        } catch (ClassNotFoundException e) {
            msg = "error,加载驱动类出错";
        }
        return jsonTemp.replace("#1", String.valueOf(b)).replace("#2", msg);
    }
}
